﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package mochicrypt.as3 {

    public class MochiCoins {

        public static const STORE_HIDE:String = "StoreHide";
        public static const LOGGED_IN:String = "LoggedIn";
        public static const NO_USER:String = "NoUser";
        public static const PROPERTIES_SIZE:String = "PropertiesSize";
        public static const IO_ERROR:String = "IOError";
        public static const STORE_ITEMS:String = "StoreItems";
        public static const USER_INFO:String = "UserInfo";
        public static const LOGIN_SHOW:String = "LoginShow";
        public static const PROFILE_HIDE:String = "ProfileHide";
        public static const STORE_SHOW:String = "StoreShow";
        public static const ITEM_NEW:String = "ItemNew";
        public static const ITEM_OWNED:String = "ItemOwned";
        public static const PROPERTIES_SAVED:String = "PropertySaved";
        public static const WIDGET_LOADED:String = "WidgetLoaded";
        public static const ERROR:String = "Error";
        public static const LOGGED_OUT:String = "LoggedOut";
        public static const PROFILE_SHOW:String = "ProfileShow";
        public static const LOGIN_HIDE:String = "LoginHide";
        public static const LOGIN_SHOWN:String = "LoginShown";

        public static var _user_info:Object = null;
        private static var _dispatcher:MochiEventDispatcher = new MochiEventDispatcher();

        public static function getUserInfo():void{
            MochiServices.send("coins_getUserInfo");
        }
        public static function showItem(_arg1:Object=null):void{
            if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
                trace("ERROR: showItem call must pass an Object with an item key");
                return;
            };
            MochiServices.bringToTop();
            MochiServices.send("coins_showItem", {options:_arg1}, null, null);
        }
        public static function getVersion():String{
            return (MochiServices.getVersion());
        }
        public static function saveUserProperties(_arg1:Object):void{
            MochiServices.send("coins_saveUserProperties", _arg1);
        }
        public static function triggerEvent(_arg1:String, _arg2:Object):void{
            if (_arg1 == LOGGED_IN){
                _user_info = _arg2;
            } else {
                if (_arg1 == LOGGED_OUT){
                    _user_info = null;
                };
            };
            _dispatcher.triggerEvent(_arg1, _arg2);
        }
        public static function removeEventListener(_arg1:String, _arg2:Function):void{
            _dispatcher.removeEventListener(_arg1, _arg2);
        }
        public static function getStoreItems():void{
            MochiServices.send("coins_getStoreItems");
        }
        public static function showLoginWidget(_arg1:Object=null):void{
            MochiServices.setContainer();
            MochiServices.bringToTop();
            MochiServices.send("coins_showLoginWidget", {options:_arg1});
        }
        public static function addEventListener(_arg1:String, _arg2:Function):void{
            _dispatcher.addEventListener(_arg1, _arg2);
        }
        public static function showStore(_arg1:Object=null):void{
            MochiServices.bringToTop();
            MochiServices.send("coins_showStore", {options:_arg1}, null, null);
        }
        public static function hideLoginWidget():void{
            MochiServices.send("coins_hideLoginWidget");
        }
        public static function getAPIURL():String{
            if (!_user_info){
                return (null);
            };
            return (_user_info.api_url);
        }
        public static function getAPIToken():String{
            if (!_user_info){
                return (null);
            };
            return (_user_info.api_token);
        }
        public static function showVideo(_arg1:Object=null):void{
            if (((!(_arg1)) || (!((typeof(_arg1.item) == "string"))))){
                trace("ERROR: showVideo call must pass an Object with an item key");
                return;
            };
            MochiServices.bringToTop();
            MochiServices.send("coins_showVideo", {options:_arg1}, null, null);
        }

    }
}//package mochicrypt.as3 
